﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZK.Entity;
using Utils.Common;
using SQLiteDB;
using System.Data;
using System.Threading;
using ZK.Entity.Config;

namespace ZK.BLL
{
   public class ProductInfoBLL
    {


        private ProductInfoBLL() { }
        /// <summary>
        /// 窗体对象实例
        /// </summary>
        private static ProductInfoBLL _instance;
        public static ProductInfoBLL Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new ProductInfoBLL();
                return _instance;
            }
        }


        public string GetNewID()
        {
            return BaseIdGenerator.Instance.GetId();
        }

        public ProductInfo GetEntity(string matCode)
        {
            string sql = "Select * from ProductInfo Where MatCode='"+ matCode + "'";
            return SQLiteORM.Instance.GetEntity<ProductInfo>(sql);
        }
        public List<ProductInfo> GetList()
        {
           string sql = "select * from ProductInfo Order BY CustomerName ";
           return  SQLiteORM.Instance.GetEntityList<ProductInfo>(sql);
        }

 

        public bool InsertList(List<ProductInfo> list)
        {
            return SQLiteORM.Instance.InsertListByTransaction<ProductInfo>(list);
        }


        public bool Insert ( ProductInfo productInfo)
        {
            return SQLiteORM.Instance.Insert<ProductInfo>(productInfo);
        }


        public bool Update(ProductInfo productInfo)
        {
            return SQLiteORM.Instance.Update(productInfo, nameof(ProductInfo.Id));
        }


        public bool Delete(string  id)
        {
            return SQLiteORM.Instance.Delete($"Delete from ProductInfo WHERE ID='{id}'");
        }

        public bool DeleteAll()
        {
            return SQLiteORM.Instance.Delete("Delete from ProductInfo");
        }



 
    }
}
